import {requestDel, requestGet, requestPatch, requestPost} from "./request";

const baseUrl = "/user/"

export async function getUserList({name, username, groups, order = 'date_joined', page = 1, page_size = 10}) {
	return await requestGet(baseUrl, {name, username, groups, order, page, page_size})
}

export async function addUserToServer(user) {
	return await requestPost(baseUrl, user)
}

export async function updateUser(user) {
	return await requestPatch(baseUrl + user.id + "/", user)
}

export async function deleteUser(id) {
	return await requestDel(baseUrl + id + "/")
}

export async function changePassword({old_password, password, password_repeat}) {
	return await requestPost(baseUrl + "change_password/", {old_password, password, password_repeat})
}
